package cn.com.guage.dtm.jubian;
import java.util.Scanner;

public class 搜索矩阵2 {
    public static int search_matrix(String[] matrix) {
        int rows = matrix.length;
        int cols = matrix[0].length();
        int[][] dp = new int[rows][cols];
        int maxSide = 0;

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                if (matrix[i].charAt(j) == '1') {
                    if (i == 0 || j == 0) {
                        dp[i][j] = 1;
                    } else {
                        dp[i][j] = Math.min(Math.min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;
                    }
                    maxSide = Math.max(maxSide, dp[i][j]);
                }
            }
        }
        return maxSide * maxSide;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        scanner.nextLine();
        String[] matrix = new String[n];
        for (int i = 0; i < n; i++) {
            matrix[i] = scanner.nextLine();
        }
        System.out.println(search_matrix(matrix));
        scanner.close();
    }
}